Skip to main content

require

Type

command

Summary

Executes the given script in the context of the global environment.

Syntax

require <script>

Description

Executes the given script in the context of the global environment, but only if it has not previously been included or required.

This is the same as the include command in operation, except it makes it easy to implement 'include-once' files and is designed primarily for library scripts.

Scripts are parsed in full before being executed, with any handler and variable definitions being added to the home stack environment before any commands placed at global scope are executed. These are ordered by encounter in the file. As require is a command, the parse-before-execute effect only extends as far as the end of the current file.

note

include and require are distinct in the sense that if you require a file and then include, the second include executes the file.

Parameters

NameTypeDescription

script

The name of the script that is to be included.

Examples

require "myScript"

command: include

Compatibility and Support

Introduced

LiveCode 4.6.3

OS

mac

windows

linux

Platforms

server

Thank you for your feedback!

Was this page helpful?